/**
 业主详情页面
 **/
(function (vc) {
    vc.extends({
        data: {
            goldInfo: {
                goldId: "",
                goldName: '',
                amount: "",
                communityName: "",
                communityId: "",
                _currentTab: 'goldDetail',
            }
        },
        _initMethod: function () {

            $that._loadGoldInfo();
          
        },
        _initEvent: function () {
            vc.on('gold', 'listGoldData', function (_info) {
                $that._loadGoldInfo();
                $that.changeTab($that.goldInfo._currentTab);
            });
            vc.on('goldWithdrawal', 'listGoldWithdrawal',function(){
                $that.goldInfo._currentTab = 'applyWithholdGold';
                $that.changeTab($that.goldInfo._currentTab);
            })
        },
        methods: {
            _loadGoldInfo: function () {
                let param = {
                    params: {
                        page: 1,
                        row: 1,
                        communityId: vc.getCurrentCommunity().communityId,
                        mallApiCode:'queryPropertyGoldBmoImpl'
                    }
                }
                //发送get请求
                vc.http.apiGet('/mall.getMallOpenApi',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        vc.copyObject(_json.data[0], $that.goldInfo);
                        $that.changeTab($that.goldInfo._currentTab);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            changeTab: function (_tab) {
                $that.goldInfo._currentTab = _tab;
                vc.emit(_tab, 'switch', {
                    goldId: $that.goldInfo.goldId,
                    goldName: $that.goldInfo.goldName,
                });
            },
            _openApplyWithholdGold:function(){
                vc.emit('withholdGold', 'openWithholdGoldModal',{
                    goldId:$that.goldInfo.goldId,
                    amount:$that.goldInfo.amount,
                    communityId:$that.goldInfo.communityId,
                })
            }
        }
    });
})(window.vc);